import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:lovelivemusicplayer/pages/scan/logic.dart';
import 'package:mobile_scanner/mobile_scanner.dart';

class ScannerPage extends GetView<ScanController> {
  const ScannerPage({super.key});

  void _handleBarcode(BarcodeCapture barcodes) {
    if (!controller.isProcessing) {
      Get.back(result: barcodes.barcodes.first.displayValue);
    }
    controller.isProcessing = true;
  }

  @override
  Widget build(BuildContext context) {
    return SizedBox(
        width: 250.h,
        height: 250.h,
        child: MobileScanner(onDetect: _handleBarcode));
  }
}
